//#region 前端js
try {

    if (Zepto) {
        ; (function ($) {
            $.extend($.fn,
            {
                getOptionText: function () {
                    return $(this).find('option').not(function () { return !this.selected }).text();
                }
            })
        })(Zepto);

        //设计组公共方法
        ; (function ($) {
            $.extend(
    {
        prompt: function (config) {
            var pWidth = "60%";
            var pHeight = "10%";
            if (config.width) {
                pWidth = config.width;
            }
            if (config.height) {
                pHeight = config.height;
            }
            var currentDot = $("<div />", {
                id: "mask"
            })
            var promptBox = $("<div />", {
                class: 'prompt-box',
                css: {
                    width: pWidth,
                    height: pHeight
                },
                text: config.text
            });

            currentDot.appendTo("body");
            promptBox.appendTo("body");

            $(document).ready(function () {
                PH = 0 - $(".prompt-box").height() / 2
                PW = 0 - $(".prompt-box").width() / 2
                $(".prompt-box").css({ marginLeft: PW, marginTop: PH })
            });

            $(window).resize(function () {
                PH = 0 - $(".prompt-box").height() / 2
                PW = 0 - $(".prompt-box").width() / 2
                $(".prompt-box").css({ marginLeft: PW, marginTop: PH })
            });




            $(".prompt-box").tap(function () {
                return false;
            })

            $("#mask").tap(function () {
                $(".prompt-box").remove();
                $("#mask").remove();
                if (config.callback) {
                    config.callback();
                }
            });
            if (config.timeout) {
                setTimeout(function () {
                    $(".prompt-box").remove();
                    $("#mask").remove();
                    if (config.callback) {
                        config.callback();
                    }

                }, config.timeout * 1000);
            }
        },
        hideBox: function () {
            $(".prompt-box").tap(function () {
                return false;
            })
            $(document).tap(function () {
                $(".prompt-box").remove();
                $("#mask").remove();
            })
        },
        loading: function (timeout, callback) {
            var loadingBox = $("<div class='loading-box'><div class='spinner'><div class='spinner-container container1'>"
                    + "<div class='circle1'></div>"
                   + "<div class='circle2'></div>"
                    + "<div class='circle3'></div>"
                    + "<div class='circle4'></div>"
                  + "</div>"
                  + "<div class='spinner-container container2'>"
                    + "<div class='circle1'></div>"
                    + "<div class='circle2'></div>"
                    + "<div class='circle3'></div>"
                    + "<div class='circle4'></div>"
                  + "</div>"
                  + "<div class='spinner-container container3'>"
                    + "<div class='circle1'></div>"
                    + "<div class='circle2'></div>"
                    + "<div class='circle3=div>"
                    + "<div class='circle4'></div>"
                   + "</div></div></div>");

            if (!arguments[0] || (typeof arguments[0] === "function")) {
                timeout = 2;
            }

            setTimeout(function () {
                $(".loading-box").remove();
                if (arguments[1]) {
                    callback();
                }
            }, timeout * 1000);


            loadingBox.appendTo("body");

        },
        loadingEnd: function (callback) {
            $(".loading-box").remove();
            if (callback) {
                callback();
            }
        },

        online1: function () {
            var onlineNode = $('<aside class="right-side-bar">'
                    + '<a id="onlineServer" href="javascript:loadChat();"><i></i><span>客服</span></a>'
                    + '<a id="go-top" style="display:none;" href="javascript:void(0);"><i></i><span>置顶</span></a>'
                + '</aside>');
            onlineNode.appendTo("body");
            if ($("#go-top")) {
                $("#go-top").click(function (event) {

                    //直接返回顶部，注释为过渡效果
                    $(window).scrollTop(0);

                    event.stopPropagation();

                })
            }

            $(window.document).scroll(function () {
                if ($(window).scrollTop() < $(window).height()) {
                    $("#go-top").hide();
                }
                else {
                    $("#go-top").show();
                }
            })
        },

        online2: function () {
            var onlineNode = $('<aside class="right-side-bar">'
                    + '<a id="onlocation" href="javascript:void(0);"><i></i><span>全国</span></a>'
                    + '<a id="onlineServer" href="javascript:loadChat();"><i></i><span>客服</span></a>'
                    + '<a id="go-top" style="display:none;" href="javascript:void(0);"><i></i><span>置顶</span></a>'
                + '</aside>');
            onlineNode.appendTo("body");
            if ($("#go-top")) {
                $("#go-top").click(function (event) {

                    //直接返回顶部，注释为过渡效果
                    $(window).scrollTop(0);

                    event.stopPropagation();

                })
            }
            $(window.document).scroll(function () {
                if ($(window).scrollTop() < $(window).height() * 0.4) {
                    $("#go-top").hide();
                }
                else {
                    $("#go-top").show();
                }
            })
        },

        online3: function () {
            var onlineNode = $('<aside class="right-side-bar">'
                    + '<a id="onlineServer" href="javascript:loadChat();"><i></i><span>客服</span></a>'
                    + '<a id="onserch" href="' + WapMallServer + '/search/newindex"><i></i><span>搜索</span></a>'
                    + '<a id="go-top" style="display:none;" href="javascript:void(0);"><i></i><span>置顶</span></a>'
                + '</aside>');
            onlineNode.appendTo("body");
            if ($("#go-top")) {
                $("#go-top").click(function (event) {

                    //直接返回顶部，注释为过渡效果
                    $(window).scrollTop(0);

                    event.stopPropagation();

                })
            }
            $(window.document).scroll(function () {
                if ($(window).scrollTop() < $(window).height() * 0.4) {
                    $("#go-top").hide();
                }
                else {
                    $("#go-top").show();
                }
            })
        },

        maskDisplay: function (callback) {
            var maskBox = $("<div/>", {
                id: "mask"
            });
            maskBox.appendTo("body");
            if (callback) {
                callback();
            }
        },

        maskHide: function () {
            $("#mask").remove();
            //$(window).unbind("touchmove");
        },
        //返回首页
        onBackIndex: function () {
            var goTop = $("<a id='backIndex' href='" + WapMallServer + "/' class='backIndex'><img src='" + ImageCssServer + "/Images/ico-back.png' alt=''></a>");
            goTop.appendTo("body");
        },

        // 头部右侧弹窗
        headNavPop: function () {
            $(".nav-button").on("click", function (event) {
                event.stopPropagation();
                if ($(".bar-list").css('display') == "none") {
                    $(".bar-list").show();
                } else {
                    $(".bar-list").hide();
                }
            })
            $(document).on("click", function () {
                $(".bar-list").hide();
            })
        }
    })
        })(Zepto)
    }
} catch (e) {

}
//#endregion


/* File Crea"ted: 十一月 12, 2013 */

//#region  全局变量
//wap登录项目
var Passprot = "";
var cprovince, ccity, carea;
var cprovinceName = "";
var ccityName = "";
var careaName = "";
//#endregion

//#region  公共方法

//#region 头部轮播方法 
//picCount: 图片个数  UlId:嵌套图的ulid DivContentId:最外层DivId
function bannerFn(picCount, UlId, DivContentId) {
    $("#" + UlId).css({ width: picCount + "00%", position: "relative" });
    //$(".pic-num1").css("width", (picCount * 30) + "px");
    var forEach = function (array, callback) {
        for (var i = 0, len = array.length; i < len; i++) { callback.call(this, array[i], i); }
    }
    var st = createPicMove(DivContentId, UlId, picCount); //图片数量更改后需更改此数值
    var nums = [];
    //插入数字
    if (st._count > 1) {
        for (var i = 0, n = st._count - 1; i <= n; i++) {
            var li = document.createElement("li");
            nums[i] = document.getElementById("idNum").appendChild(li);
        }
    }
    //设置按钮样式
    st.onStart = function () {
        forEach(nums, function (o, i) { o.className = st.Index == i ? "new-tbl-cell on" : "new-tbl-cell"; })
    }
    // 重新设置浮动
    $("#" + UlId).css({ width: picCount + "00%", position: "relative" });

    var _initX = 0;
    var _finishX = 0;
    var _startX = 0;
    var _startY = 0;
    $("#" + DivContentId).on("touchstart", function (event) {
        _startX = event.touches[0].clientX;
        _startY = event.touches[0].clientY;
        _initX = _startX;
    })
    $("#" + DivContentId).on("touchmove", function (event) {
        var touches = event.touches;
        var _endX = event.touches[0].clientX;
        var _endY = event.touches[0].clientY;
        if (Math.abs(_endY - _startY) > Math.abs(_endX - _startX)) {
            return;
        }
        event.preventDefault();
        _finishX = _endX;
        var _absX = Math.abs(_endX - _startX);
        var lastX = $('#' + UlId).css('left').replace('px', '');
        if (_startX > _endX) {
            st.Stop();
            $('#' + UlId).css('left', (parseInt(lastX) - _absX) + 'px');
        } else {
            st.Stop();
            $('#' + UlId).css('left', (parseInt(lastX) + _absX) + 'px');
        }
        _startX = _endX;
    })
    $("#" + DivContentId).on("touchend", function (event) {
        if (_finishX == 0) {
            return;
        }
        if (_initX > _finishX) {
            bindEvent(_initX, _finishX);
        } else if (_initX < _finishX) {
            bindEvent(_initX, _finishX);
        }
        _initX = 0;
        _finishX = 0;
    })
    /**
    *  绑定触屏触发事件
    * @param start
    * @param end
    */
    function bindEvent(start, end) {
        if (start >= end) {
            st.Next();
        } else {
            st.Previous();
        }
    }
    st.Run();
    var resetScrollEle = function () {
        //$("#shelper").css("width", $("#newkeyword").width() + "px");
        var slider2Li = $("#" + UlId + " li");
        slider2Li.css("width", $(".banner").width() + "px");
        //$("#shelper").css("width", $("#newkeyword").width() + "px");
    }

    window.addEventListener("resize", function () {
        st.Change = st._slider.offsetWidth / st._count;
        st.Next();
        resetScrollEle();
    });
    window.addEventListener("orientationchange", function () {
        st.Change = st._slider.offsetWidth / st._count;
        st.Next();
        resetScrollEle();
    })
    resetScrollEle();
}
//#endregion

//#region 顶部搜索
function doSearchByKeyword() {
    var url = "";
    if ($("#newkeyword")[0] != null) {
        var keyinput = $("#newkeyword");
        var keyword = keyinput.val().trim();
        url = keyword.length > 0 ? "/list/?q=" + $("#newkeyword").val().trim() : "/search/newIndex";
        //跳转到默认关键字地址
        if (validate.isNull(keyword)) {
            var link = keyinput.attr("hotlink");
            if (!validate.isNull(link)) {
                url = link;
            }
        }   
    } else {
        url = "/search/newindex";
    }
    window.location.href = WapMallServer + url;

}
//#endregion

//#region 公用弹窗
//msg:信息 timeout：关闭时间 callback:回调函数
function alertInfo(msg, timeout, callback) {
    if (typeof arguments[1] === "function") {
        callback = timeout;
        timeout = 1111;
    } else if (!arguments[1]) {
        timeout = 1111;
    }
    $(window).prompt({ text: msg, callback: callback, timeout: timeout });
}
//#endregion

//#region 后退
function GoBack() {
    history.go(-1);
}  
//#endregion

//#region 异步加载更多
$.asynload = function (opts) {
    opts = $.extend({
        maxpage: 1,
        url: "",
        data: {},
        pageIndex: 2,
        success: function () { },
        end: function () { },
        error: function () { }
    }, opts || {});
    var pageIndex = opts.pageIndex;
    var loading = true; //正在加载
    $(window).unbind("scroll");
    if (opts.maxpage <= 1) {
        opts.end();
    };

    $(window).scroll(function () {
        var $body = $("body");
        /*判断窗体高度与竖向滚动位移大小相加 是否 超过内容页高度*/
        if (($(window).height() + $(window).scrollTop()) >= $body.height()) {
            if (loading) {
                loading = false;
                opts.data.pageIndex = pageIndex
                $.ajax({
                    cache: false,
                    url: opts.url,
                    data: opts.data,
                    success: function (data) {
                        var jsonData = {
                            data: data,
                            pageIndex: pageIndex
                        };
                        opts.success(jsonData);
                        if (pageIndex >= opts.maxpage) {
                            $(window).unbind("scroll");
                            opts.end();
                        }
                        pageIndex++;
                        loading = true;
                    },
                    error: function (e) {
                        opts.error();
                        loading = true;
                    }
                });
            }
        }
    });
}
//#endregion

//#region 传入中间件返回的Result，判断是否登录
function checkloginJs() {
    if (!islogin) {
        location.href = Passprot + "/login.html?returl=" + escape(window.location.href);
        return false;
    }
    return true;
}
//#endregion

//#region jqcookie

function jqcookie(key, value, options) {
    //当前页面地址
    var curUrl = window.location.href.toString().toLowerCase();
    var domain = "";
    if (curUrl.indexOf("yhjj.com") > 0) {
        domain = "yhjj.com";
    }
    else if (curUrl.indexOf("yihaojiaju.com") > 0) {
        domain = "yihaojiaju.com";
        if (key == "tokenId") {
            key = "passport_token";
        }
    }


    if (arguments.length > 1 && (value === null || typeof value !== "object")) {
        options = $.extend({}, options);
        if (value === null) {
            options.expires = -1;
        }
        if (typeof options.expires === 'number') {
            var days = options.expires, t = options.expires = new Date();
            t.setDate(t.getDate() + days);
        }
        options.path = '/';
        options.domain = domain;
        return (document.cookie = [encodeURIComponent(key), '=', options.raw ? String(value) : encodeURIComponent(String(value)), options.expires ? '; expires=' + options.expires.toUTCString() : '', options.path ? '; path=' + options.path : '', options.domain ? '; domain=' + options.domain : '', options.secure ? '; secure' : ''].join(''));
    }
    options = value || {};
    options.path = '/';
    options.domain = domain;
    var result, decode = options.raw ? function (s) {
        return s;
    } : decodeURIComponent;
    return (result = new RegExp('(?:^|; )' + encodeURIComponent(key) + '=([^;]*)').exec(document.cookie)) ? decode(result[1]) : null;
};

//#endregion

//#region 设置省市区cookie   
//cprovince:省ID ccity：市ID carea：区ID locationName："省,市,区,"
function SetCityCookie(cprovince, ccity, carea, locationName) {
    jqcookie("ClientProvince", cprovince);
    jqcookie("ClientCity", ccity);
    jqcookie("ClientArea", carea);
    jqcookie("citylocation", locationName);
    jqcookie("cprovinceName", locationName.split(',')[0]);
    jqcookie("ccityName", locationName.split(',')[1]);
    jqcookie("careaName", locationName.split(',')[2]);
    
}
//#endregion

//#region 获取购物车数量
function GetCartNum() {
    $.post(WapMallServer + "/Cart/GetCartNum", { "CityId": jqcookie("ClientCity") }, function (json) {
        return parseInt(json);
    }); 
}
//#endregion

//#region 获取打开使用的操作系统
function GetToSystem(href) {
    //平台、设备和操作系统
    var system = {
        win: false,
        mac: false,
        xll: false
    };
    //检测平台
    var p = navigator.platform;
    system.win = p.indexOf("Win") == 0;
    system.mac = p.indexOf("Mac") == 0;
    system.x11 = (p == "X11") || (p.indexOf("Linux") == 0);
    //跳转语句
    if (system.win || system.mac || system.xll) {//转向后台登陆页面++++
        window.location.href = href;
    } else {
        return false;
    }
}

//#endregion

//#region  领取优惠券
function sendCounponForKey(couponNoKey) {
    $.post(WapMallServer + "/_2015/sendCounponForKey", { "couponNoKey": couponNoKey }, function (result) {
        if (result.Success) {
            alertInfo("成功领取优惠券!", null, 3);
        } else {
            if ("1300" == result.Code) {
                //跳转登录页
                location.href = Passprot + "/login.html?returl=" + escape(window.location.href);
                return false;
            } else {
                alertInfo(result.Message, null, 3);
            }
        }

    });
}

//#endregion

//公用倒计时
//targetDate:倒计时开始时间 nowDate:当前时间 
//idday：  标签天  Id或Class 
//idhour:  标签小时...........
//idminute:标签分钟...........
//idsecond:标签秒  ...........
//classtype: true 标签为Class  其它为 Id
function ComCountdown(targetDate, nowDate, idday, idhour, idminute, idsecond, classtype, callback) {
    var timer = null;
    var result = null;
    function getTime() {
        result = (targetDate - nowDate);

        if (result == 0) {
            if (typeof (callback) === 'function') {
                callback();
            }
        }

        if (result < 0) {
            return false;
        }

        var day = parseInt(result / (24 * 60 * 60 * 1000));
        var dayint = day;
        var hour = parseInt((result - day * (24 * 60 * 60 * 1000)) / (60 * 60 * 1000));
        var minute = parseInt((result - day * (24 * 60 * 60 * 1000) - hour * (60 * 60 * 1000)) / (60 * 1000));
        var second = parseInt((result - day * (24 * 60 * 60 * 1000) - hour * (60 * 60 * 1000) - minute * (60 * 1000)) / 1000);
        if (day < 10) {
            day = "0" + day
        }
        if (minute < 10) {
            minute = "0" + minute
        }
        if (hour < 10) {
            hour = "0" + hour
        }
        if (second < 10) {
            second = "0" + second
        }

        if (classtype == true) {
            if (!validate.isNull(idday)) {
                $("." + idday + "").text(day);
            } else {
                if (dayint > 0) {
                    hour = parseInt(hour) + dayint * 24;
                }
            }
            $("." + idhour + "").text(hour);
            $("." + idminute + "").text(minute);
            $("." + idsecond + "").text(second);
        } else {
            if (!validate.isNull(idday)) {
                $("#" + idday + "").text(day);
            } else {
                if (dayint > 0) {
                    hour = parseInt(hour) + dayint * 24;
                }
            }
            $("#" + idhour + "").text(hour);
            $("#" + idminute + "").text(minute);
            $("#" + idsecond + "").text(second);
        }

        targetDate = targetDate - 1000;

    }
    //getTime();
    timer = setInterval(function () {
        getTime();
    }, 1000)

}


//#endregion

//#region 数据验证
var validate = {
    isInteger: function (val) {//验证正整数，包括0
        var patten = /^[1-9]\d*|0$/;
        return patten.test(val);
    },

    isIdcard: function (val) {//验证身份证 
        var patten = /^\d{15}(\d{2}[A-Za-z0-9])?$/;
        return patten.test(val);
    },

    idPhone: function (val) {//验证电话号码 
        var patten = /^((\(\d{2,3}\))|(\d{3}\-))?(\(0\d{2,3}\)|0\d{2,3}-)?[1-9]\d{6,7}(\-\d{1,4})?$/;
        return patten.test(val);

    },

    isMobile: function validateNum(val) {// 验证手机号码 
        var patten = /^(13|15|17|18)\d{9}$/;
        return patten.test(val);

    },

    isTelephone: function (val) { //验证手机或电话号
        var patten = /^(((13[0-9]{1})|(15[0-9]{1})|(18[0-9]{1})|(0[0-9]{2,3}))+\d{7,8})$/;
        return patten.test(val);
    },

    isEmail: function (val) {//验证email账号
        var patten = /^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/;
        return patten.test(val);
    },

    isNum: function (val) {//验证整数
        var patten = /^-?\d+$/;
        return patten.test(val);
    },

    isRealNum: function (val) {//验证实数 
        var patten = /^-?\d+\.?\d*$/;
        return patten.test(val);

    },

    isFloat2: function validateNum(val) {//验证小数，保留2位小数点 
        var patten = /^-?\d+\.?\d{0,2}$/;
        return patten.test(val);

    },

    isFloat: function (val) {//验证小数
        var patten = /^-?(?:\d+|\d{1,3}(?:,\d{3})+)(?:\.\d+)?$/;
        return patten.test(val);
    },

    isNumOrLetter: function (val) {//只能输入数字和字母
        var patten = /^[A-Za-z0-9]+$/;
        return patten.test(val);
    },

    isColor: function (val) {//验证颜色
        var patten = /^#[0-9a-fA-F]{6}$/;
        return patten.test(val);
    },

    isUrl: function (val) { //验证URL
        var patten = /^(https?|ftp):\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i;
        return patten.test(val);
    },

    isNull: function (val) {//验证空
        if (val) {
            return val.replace(/\s+/g, "").length == 0;
        }
        return true;
    },

    isData: function (val) {//验证时间2010-10-10
        var patten = /^\d{4}[\/-]\d{1,2}[\/-]\d{1,2}$/;
        return patten.test(val);
    },

    isNumLetterLine: function (val) {//只能输入数字、字母、下划线
        var patten = /^[a-zA-Z0-9_]{1,}$/;
        return patten.test(val);
    }
}
//#endregion



$(function () {

    //登录项目地址
    Passprot = $("#WapPassport").val();

    setTimeout(' window.scrollTo(0,0);', 2000);

    //#region 延迟加载    
    $(".test-lazyload").picLazyLoad({
        threshold: 200,
        placeholder: ''
    });
    //#endregion

    //#region 右侧栏显示与隐藏
    if (!$("#rightSibar") || $("#rightSibar").val() != "1") {
        if ($("#channelright").val() == "2") {
             $(window).online2();
        } else if ($("#channelright").val() == "3") {
             $(window).online3();
        } else {
             $(window).online1();
        }
    }

    //#endregion

    //#region 顶部弹窗显示与隐藏
    $(window).headNavPop();
    //#endregion

    //#region  搜索文本的清除
    $("a.esc").click(function () {
        $("#newkeyword").val("");
        $(this).hide();
    });

    $("#newkeyword").keyup(function () {
        if (this.value.trim() == "") {
            $("a.esc").hide();
        } else {
            $("a.esc").show();
        }
    });
    //#endregion

    //#region 设置顶部登录头像
    $.get(WapMallServer + "/Home/getUser?t" + Math.random() * 999, function (userInfo) {
        islogin = userInfo.isLogin;
        if (userInfo.isLogin) {
            if (!validate.isNull(userInfo.ImgPortrait)) {
                $("#toplogin").attr("src", userInfo.ImgPortrait);
            }
        }
    }, "json");
    //#endregion

    //#region 设置省市区

    //判断 cookie是否为null
    cprovince = jqcookie("ClientProvince");
    ccity = jqcookie("ClientCity");
    carea = jqcookie("ClientArea");
    var location = jqcookie("citylocation");
    cprovinceName = jqcookie("cprovinceName");
    ccityName = jqcookie("ccityName");
    careaName = jqcookie("careaName");

    //如果市为空
    if (!location || !ccity || validate.isNull(ccity) || validate.isNull(location)) {
        $.get(WapMallServer + "/sys/getcityforip", function (json) {
            cprovince = json.provinceId; //省
            ccity = json.cityId;        //市
            carea = json.areaId;        //区    
            SetCityCookie(cprovince, ccity, carea, json.locationName);
            if (typeof getCityForIP === "function") {
                getCityForIP(json.locationName);

            }
        });
    }

    //#endregion

});



